<!--用户管理-->
<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="superTablePage">
    </ex_super_table_page>

    <ex_image_view ref="previewImage" style="width: 100px; height: 100px;display:none;"
                   :src="previewUrls.length == 0 ? '' : previewUrls[0]" :preview-src-list="previewUrls" fit="scale-down">
    </ex_image_view>

  </div>
</template>
<script>


  export default {

    title: 'title_account_fund_flow',
    components: {},

    data() {

      let _this = this

      return {
        previewUrls: [],
        dialogFormVisible: false,
        dialogTitle: '',
        formValue: {
          'type': 'DONE'
        },
        rules: {}

      };
    },

    watch: {
      'formValue.companyId'(val, old) {
      }
    },

    created() {

      let _this = this

      _this.option = {
        search: {
          model: [
            {
              label: "label_serial_number", key: "accountLogNo" , attrs: { clearable: true },
            },
            {
              label: "label_account_type", key: "accountType", type: 'select', enum: 'CustomerAccountTypeEnum', attrs: { clearable: true },
            },
            // {
            //   label: "适用产品", key: "productType", type: 'select', enum: 'PmsProductTypeEnum', attrs: { clearable: true },
            // },
            {
              label: "label_business_type", key: "modifyType", type: 'select', enum: 'AccountModifyTypeEnum', attrs: { clearable: true },
            },
            { label: "label_business_order_code", key: "refOrderNo" },
            {
              label: "label_order_type", key: "refOrderType" ,type: 'select', enum: 'OrderTypeEnum', attrs: { clearable: true },
            },
            {
              label: 'label_happen_time', key: "happenTime", type: 'date-picker', attrs: { clearable: true }, fold: true,
            }
          ]
        },
        action: [],

        table: {
          url: "/fms-api/client/FmsClientRpc/selectAccountLog.json",
          attrs: {
            'cell-style': ({row, column, rowIndex, columnIndex}) => {
              if (column.property == 'status') {
                return {color: row.status == 'NORMAL' ? this.$globalCss.successColor : this.$globalCss.infoColor}
              }
            }
          },
          model: [
            {key: 'accountLogNo', label: 'label_serial_number', align: 'left'},
            {
              key: 'accountType', label: 'label_account', width: 200,
              attrs: {
                formatter: (r, c, v, i) => {
                  return (r.accountType == 'CREDIT' ? (this.$enumShow(r.productType, 'PmsProductTypeEnum') + '-') : '' ) + this.$enumShow(r.currencyType, 'CurrencyTypeEnum') + '-' + this.$enumShow(r.accountType, 'CustomerAccountTypeEnum')
                }
              }
            },


            {
              key: 'inOutType', label: 'label_serial_type', align: 'center', width: 120,
              attrs: {
                formatter: (r, c, v, i) => {
                  return this.$enumShow(v, 'AccountInOutTypeEnum')
                }
              }
            },
            {
              key: 'modifyType', label: 'label_business_type', align: 'center', width: 120,
              attrs: {
                formatter: (r, c, v, i) => {
                  return this.$enumShow(v, 'AccountModifyTypeEnum')
                }
              }
            },

            {
              key: 'modifyLockAmount', label: 'label_withholding_amount_change',minWidth: 140
            },
            {
              key: 'lockAmount', label: 'label_withholding_total_amount',minWidth: 140,
            },
            {
              key: 'modifyLeftAmount', label: 'label_deduction_amount',minWidth: 140,
            },
            {
              key: 'leftAmount', label: 'label_available_amount_quota',minWidth: 140,
            },
            {
              key: 'totalAmount', label: 'label_fms_account_log_total_amount',minWidth: 140,
            },


            {
              key: 'refOrderType', label: 'label_order_type', align: 'center', width: 230,
              attrs: {
                formatter: (r, c, v, i) => {
                  if (r.refOrderNo) {
                    return this.$enumShow(v, 'OrderTypeEnum') + '-' + r.refOrderNo
                  }
                  return '-'
                }
              }
            },
            {
              key: 'remark', label: 'label_remark', align: 'center', width: 200,
              render: (h, { row, column }) => {
                const code = row[column.property]
                return (<text_extra_tooltip_operate
                  value={code} ellipsis
                  data_type={column.property} data_id={row.id}
                />)
              },
            },
            {
              key: 'happenTime', label: 'label_happen_time', width: 160,  attrs: {
                formatter: (r, c, v, i) => {
                  return this.$dateFormat(v)
                }
              }
            },
            {
              type: 'operate', width: 120,
              operate: [
                {
                  label: 'label_fms_account_pay_photo',
                  if: (row) => !!row.logVoucher,
                  click: (row) => {
                    this.previewUrls = [row.logVoucher]
                    // this.showViewer
                    this.$refs.previewImage.$refs.img.showViewer = true
                    // console.log(this.$refs.previewImage)
                  }
                }
              ],
            }
          ]
        }
      }

    },

    props: {},

    destroyed() {

    },

    methods: {

      renderAmount(r, totalField, modifyField){
        let str = r[totalField]
        if(r[modifyField] && r[modifyField] != 0){

          if(r[modifyField] > 0){
            str += ' (+' + r[modifyField]  +  ')'
          }
          else{
            str += ' (' + r[modifyField]  +  ')'
          }
        }
        return str
      },


      /*submitForm() {*/

      /*  let _this = this*/

      /*  _this.$refs['formEl'].validate((valid) => {*/
      /*    if (valid) {*/

      /*      _this.$ajax({*/
      /*        url: '/fms-api/client/CustomerCreditApplyRpc/audit.json',*/
      /*        // type: 'json',*/
      /*        data: _this.formValue,*/
      /*        success: (responseData) => {*/
      /*          this.$message({*/
      /*            showClose: true,*/
      /*            message: '提交成功',*/
      /*            type: 'success'*/
      /*          })*/
      /*          _this.$refs['superTablePage'].reload()*/
      /*          _this.dialogFormVisible = false*/
      /*        }*/
      /*      });*/

      //     } else {
      //       return false;
      //     }
      //
      //   });
      //
      // }


    }
  };

</script>
<style>
  .small-btn span {
    font-size: 14px;
  }

  .small-btn .el-button--small span {
    font-size: 14px;
  }
</style>
